<template>
	<view class="menu" v-if="visible">
		<view class="item" @tap="$emit('edit', item)">编辑</view>
		<view class="item" @tap="$emit('delete', item);closeMenu()">删除</view>
		<view class="item" @tap="$emit('tot_up', item);closeMenu()">置顶</view>
	</view>
</template>

<script>
	export default {
		props: ['item', 'visible'], // 接收父组件传递的新闻项
		methods: {
			closeMenu() {
				this.$emit('close');
			}
		}
	};
</script>

<style scoped lang="scss">
	.menu {
		position: absolute;
		top: 100%;
		right: 0;
		z-index: 999;
		width: 100rpx;
		background-color: #fff;
		border: 1px solid #ccc;
		border-radius: 5px;
		padding: 5px;
		box-shadow: 0 2px 8px 0 rgba(0, 0, 0, .08);

		.item {
			margin: 8px 5px;
			cursor: pointer;
		}
	}
</style>